package com.zyh.homework.test1;

import java.io.*;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Author zyh
 * @Date 2024/8/6 17:17
 * @Description
 */

public class Test1 {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String format = sdf.format(date);
        Message message = new Message("zyh", "cxk", "哥哥教我打篮球", format);
        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("D:\\Code\\IDEA\\idea_projects\\JavaSE-plus\\day10-code\\src\\com\\zyh\\homework\\test1\\message.dat"));
        oos.writeObject(message);
        oos.flush();
        oos.close();

        ObjectInputStream ois = new ObjectInputStream(new FileInputStream("D:\\Code\\IDEA\\idea_projects\\JavaSE-plus\\day10-code\\src\\com\\zyh\\homework\\test1\\message.dat"));
        Message newMessage = (Message) ois.readObject();
        System.out.println(newMessage);
    }

}
